/**
 * Created by qtbui on 2017/9/20.
 */
class Solution
{
    public int removeElement(int[] nums, int val)
    {
        int[] newNums=new int[nums.length];
        int count=0;
        for(int n:nums)
        {
            if(n!=val)
            {
                newNums[count++]=n;
            }
        }
        for(int i=0;i<count;++i)
        {
            nums[i]=newNums[i];
        }

        return count;
    }
}

public class test
{
    public static void main(String[] args)
    {
        int[] n=new int[]{3,2,2,3};
        int length=new Solution().removeElement(n,3);

        for(int i=0;i<length;++i)
        {
            System.out.print(n[i]+"\t");
        }
    }
}
